local skel = fk.CreateSkill {
  name = "emo__youzhen",
}

skel:addEffect("active", {
  anim_type = "drawcard",
  times = function (self, player)
    return 1 - player:usedSkillTimes(skel.name, Player.HistoryPhase)
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(skel.name, Player.HistoryPhase) == 0
  end,
  card_num = 0,
  card_filter = Util.FalseFunc,
  target_num = 1,
  target_filter = function (self, player, to_select, selected)
    return #selected == 0 and to_select ~= player
  end,
  prompt = "#emo__youzhen-prompt",
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local generalPile = {}
    for _, name in pairs(room.general_pile) do
      local general = Fk.generals[name]
      if general.gender == General.Female and general.kingdom == target.kingdom then
        table.insert(generalPile, general)
      end
    end
    if #generalPile > 0 then
      local general = table.random(generalPile)
      if player.deputyGeneral == "moe__jiao" or player.tag["moe__jiao_deputy"] then
        -- 用player tag记录变身前此武将是否在副将
        player.tag["moe__jiao_deputy"] = true
        room:setPlayerProperty(player, "deputyGeneral", general.name)
      else
        room:setPlayerProperty(player, "general", general.name)
      end
      room:changeKingdom(player, general.kingdom, true)
    end
    player:drawCards(1, skel.name)
  end,
})


Fk:loadTranslationTable{
  ["emo__youzhen"] = "游侦",
  [":emo__youzhen"] = "出牌阶段限一次，你可以将武将的图像变更为与一名其他角色同势力的随机女性，然后摸一张牌。",

  ["#emo__youzhen-prompt"] = "游侦：选择一名其他角色，变装为与其同势力的女性，并摸一张牌",
}

return skel
